*TAKES in RAW Data and outputs clean data
*BEPZ
*Generate and label final variables for analysis *
*****************************************
version 13.1
use "~/Dropbox/BEPZ/cps_files/raw_bepz_data.dta", clear
set more off

*drop response latencies as they are not used in the analysis
*if you are interested in these, contact the authors
drop *_latency

*drop duplicate checks on output
drop valuesaudited
drop valuesincome_postdonation
drop valuesincome_posttax
drop valuesreported_income
drop date_date*
drop time
drop _merge

label var date "Date study was administered"
drop scriptstartdate

rename valuesend_time1 end_time1
rename valuesend_time2 end_time2
label var end_time1 "Time R finished last survey questions in experiment"
label var end_time2 "Time R finished manipulation check questions in experiment"

rename group block
label var block "Female or male block"

rename start_pwd_response start_pwd
label var start_pwd "Password entered to start study"

rename end_pwd_response end_pwd
label var end_pwd "Password entered to end study"

rename scriptsubjectid subject_id
label var subject_id "Unique R id"

rename scriptstarttime start_time
label var start_time "Time R started study"

rename scriptgroupassignmentcode groupcode
label var groupcode "Inquisit assigned random number"

rename displayrefreshrate display_refresh_rate
label var display_refresh_rate "Monitor's refresh rate in Hz as measured by Inquisit"

*********************************************************
*********************************************************
**OUTCOME VARIABLES*
/*treatment*/
gen treat = .
replace treat=0 if scriptcurrentexpt=="conditionControl"
replace treat=1 if scriptcurrentexpt=="conditionSheikh"
replace treat=2 if scriptcurrentexpt=="conditionBoth"

label define treatment 0 "Control" 1 "Sheikh" 2 "Sheikh + Eyes"
label values treat treatment
label var treat "Treatment Status"

/*dichotomous treatment*/
gen treat_dichot = .
replace treat_dichot = 0 if scriptcurrentexpt=="conditionControl"
replace treat_dichot = 1 if scriptcurrentexpt=="conditionSheikh"
replace treat_dichot = 1 if scriptcurrentexpt=="conditionBoth"

label var treat_dichot "1 if R was in either Treatment, 0 if in Control"
drop scriptcurrentexpt

/*endorsements*/
gen endorse_climate = slidershclimateresponse
gen endorse_space = slidershspaceresponse
gen endorse_nukes = slidershnuclearresponse
gen endorse = (endorse_climate + endorse_space + endorse_nukes)/3

label var endorse_climate "R's thermometer rating of Sheikh's climate policy"
label var endorse_space "R's thermometer rating of Sheikh's space policy"
label var endorse_nukes "R's thermometer rating of Sheikh's nuclear policy"
label var endorse "R's mean thermometer score of all three policies"
drop slidersh*

/*compliance game*/
rename listrounds_unreported_income2 unreported_income_practice2
rename listrounds_unreported_income1 unreported_income_practice1
label var unreported_income_practice2 "R's unreported income in second practice round"
label var unreported_income_practice1 "R's unreported income in first practice round"

rename listrounds_incomes_earned2 income_earned_practice2
rename listrounds_incomes_earned1 income_earned_practice1
label var income_earned_practice2 "R's income earned in second practice round"
label var income_earned_practice1 "R's income earned in first practice round"

rename listrounds_reported_income3 reported_income
rename listrounds_reported_income2 reported_income_practice2
rename listrounds_reported_income1 reported_income_practice1
label var reported_income_practice2 "R's reported income in second practice round"
label var reported_income_practice1 "R's reported income in first practice round"
label var reported_income "R's reported income"

rename listrounds_income_post_tax3 income_post_tax
rename listrounds_income_post_tax2 income_post_tax_practice2
rename listrounds_income_post_tax1 income_post_tax_practice1
label var income_post_tax_practice2"R's post-tax income in second practice round"
label var income_post_tax_practice1 "R's post-tax income in first practice round"
label var income_post_tax "R's post-tax income"

gen income_unreported = listrounds_unreported_income3
gen income_earned = listrounds_incomes_earned3
gen percent_unreported = (income_unreported/income_earned)*100
gen percent_paid = 100-percent_unreported

label var income_unreported "R's unreported income"
label var income_earned "R's earned income" 
label var percent_unreported "Percent of R's income that was unreported" 
label var percent_paid "Percent of R's income that reported" 

drop listrounds_unreported_income3
drop listrounds_incomes_earned3

rename listrounds_audits2 audited_practice2
rename listrounds_audits1 audited_practice1
label var audited_practice2 "1 if R was audited in 2nd practice round, 0 otherwise"
label var audited_practice1 "1 if R was audited in 1st practice round, 0 otherwise"

rename listrounds_auditor1 auditor1
rename listrounds_auditor2 auditor2
rename listrounds_auditor3 auditor3
label var auditor1 "Auditor in 1st practice round of compliance game"
label var auditor2 "Auditor in 2nd practice round of compliance game"
label var auditor3 "Auditor in compliance game"

gen audited = listrounds_audits3 
label var audited "1 if R was audited, 0 otherwise"
 drop listrounds_audits3 

gen percent_paid_bin = .
replace percent_paid_bin = 0 if percent_paid == 0
replace percent_paid_bin = 1 if percent_paid  > 0 & percent_paid < 25
replace percent_paid_bin = 2 if percent_paid  >=25 & percent_paid < 50
replace percent_paid_bin = 3 if percent_paid  >=50 & percent_paid < 75
replace percent_paid_bin = 4 if percent_paid  >=75 & percent_paid < 100
replace percent_paid_bin = 5 if percent_paid  == 100
#delimit ;
label define bins_percent 
	0 "0" 
	1 "0 < x < 25" 
	2 "25 <= x < 50"
	3 "50 <= x < 75"
	4 "75 <= x < 100"
	5 "100";
	
label values percent_paid_bin bins_percent;
label var percent_paid_bin "Binned percentage of R's reported income following Cadsby et al.";
#delimit cr
*gen income = percent_paid_bin

gen complier = .
replace complier = 0 if percent_unreported > 0
replace complier = 1 if percent_unreported == 0
label var complier "1 if R reported all income, 0 otherwise"
label define complier_group 0 "Noncomplier" 1 "Complier" 
label values complier complier_group

/*donations*/
gen donation = valuesquantity_donated
gen donation_stand = (donation/income_post_tax)*100 /*donation standardized by take-home amount*/
gen donation_bin = cond(donation==0,0,1) if donation~=.
label var donation "Quantity R donated"
label var donation_stand "Quantity R donated standardized by post-tax income"
label var donation_bin "1 if R donated any income, 0 otherwise"

drop valuesquantity_donated

rename radiobuttonsdonateresponse donate_desire
label var donate_desire "Did R say they would like to make a donation"

gen donation_bin5 = .
replace donation_bin5 = 0 if donation_stand == 0
replace donation_bin5= 1 if donation_stand  > 0 & donation_stand < 25
replace donation_bin5= 2 if donation_stand  >=25 & donation_stand < 50
replace donation_bin5= 3 if donation_stand  >=50 & donation_stand < 75
replace donation_bin5= 4 if donation_stand  >=75 & donation_stand < 100
replace donation_bin5= 5 if donation_stand  == 100

label values donation_bin5 bins_percent
label var donation_bin5 "Binned percentage of R's income donated following Cadsby et al."

label var build "Inquisit version"

/*survey questions*/
/*statement "A"
> 1 = "Statement A: People should be more active in questioning the actions of leaders
> 2 = "Statement A: People are like children; the government should take care of them like a parent.
> 3 = "Statement A: Government should be able to ban any organization that goes against its policies.
> 4 = "Statement A: Government should be able to close newspapers that print stories it does not like.
> 5 = "Statement A: Government should not allow the expression of political views that are fundamentally diff
> erent from its own.
> */

gen policy_num = valuespolicy_num
label var policy_num "Checksum variable to ensure all R's got 5 compliance statements"
drop valuespolicy_num

gen comply_surv1 = . 

replace comply_surv1 = 2 if listshpolicies_answersitems1 == "strongly agree with B" | listshpolicies_answersitems1=="moderately agree with B"
replace comply_surv1 = 1 if listshpolicies_answersitems1 == "Neutral"
replace comply_surv1 = 0 if listshpolicies_answersitems1 == "strongly agree with A" | listshpolicies_answersitems1=="moderately agree with A"
label define comply 2 "compliant" 1 "neutral" 0 "noncompliant"
label values comply_surv1 comply
tab comply_surv1

gen comply_surv1exp = .
replace comply_surv1exp = -2 if listshpolicies_answersitems1 == "strongly agree with A"
replace comply_surv1exp = -1 if listshpolicies_answersitems1 == "moderately agree with A"
replace comply_surv1exp = 0 if listshpolicies_answersitems1 == "Neutral"
replace comply_surv1exp = 1 if listshpolicies_answersitems1 == "moderately agree with B"
replace comply_surv1exp = 2 if listshpolicies_answersitems1 == "strongly agree with B"
label define complyexp -2 "strongly noncompliant" -1 "moderately noncompliant" 0 "neutral" 1 "moderately compliant" 2 "strongly compliant"
label values comply_surv1exp complyexp
label var comply_surv1exp "Compliance Statement 1: Question leaders 5 point scale"

gen comply_surv1alt = comply_surv1
recode comply_surv1alt 0=-1 1=0 2=1
label define complyalt 1 "compliant" 0 "neutral" -1 "noncompliant"
label values comply_surv1alt complyalt
label var comply_surv1alt "Compliance Statement 1: Question leaders 3 point scale - +"
label var comply_surv1 "Compliance Statement 1: Question leaders 3 point scale"


gen comply_surv2 = . 
replace comply_surv2 = 2 if listshpolicies_answersitems2 == "strongly agree with A" | listshpolicies_answersitems2=="moderately agree with A"
replace comply_surv2 = 1 if listshpolicies_answersitems2 == "Neutral"
replace comply_surv2 = 0 if listshpolicies_answersitems2 == "strongly agree with B" | listshpolicies_answersitems2=="moderately agree with B"
label values comply_surv2 comply

gen comply_surv2exp = .
replace comply_surv2exp = -2 if listshpolicies_answersitems2 == "strongly agree with B"
replace comply_surv2exp = -1 if listshpolicies_answersitems2 == "moderately agree with B"
replace comply_surv2exp = 0 if listshpolicies_answersitems2 == "Neutral"
replace comply_surv2exp = 1 if listshpolicies_answersitems2 == "moderately agree with A"
replace comply_surv2exp = 2 if listshpolicies_answersitems2 == "strongly agree with A"
label values comply_surv2exp complyexp
tab comply_surv2 comply_surv2exp

gen comply_surv2alt = comply_surv2
recode comply_surv2alt 0=-1 1=0 2=1
label values comply_surv2alt complyalt
label var comply_surv2exp "Compliance Statement 2: Children v. Employee 5 point scale"
label var comply_surv2alt "Compliance Statement 2: Children v. Employee 3 point scale -+"
label var comply_surv2 "Compliance Statement 2: Children v. Employee 3 point scale"


gen comply_surv3 = . 
replace comply_surv3 = 2 if listshpolicies_answersitems3 == "strongly agree with A" | listshpolicies_answersitems3=="moderately agree with A"
replace comply_surv3 = 1 if listshpolicies_answersitems3 == "Neutral"
replace comply_surv3 = 0 if listshpolicies_answersitems3 == "strongly agree with B" | listshpolicies_answersitems3=="moderately agree with B"
label values comply_surv3 comply
tab comply_surv3

gen comply_surv3exp = .
replace comply_surv3exp = -2 if listshpolicies_answersitems3 == "strongly agree with B"
replace comply_surv3exp = -1 if listshpolicies_answersitems3 == "moderately agree with B"
replace comply_surv3exp = 0 if listshpolicies_answersitems3 == "Neutral"
replace comply_surv3exp = 1 if listshpolicies_answersitems3 == "moderately agree with A"
replace comply_surv3exp = 2 if listshpolicies_answersitems3 == "strongly agree with A"
label values comply_surv3exp complyexp
tab comply_surv3 comply_surv3exp

gen comply_surv3alt = comply_surv3
recode comply_surv3alt 0=-1 1=0 2=1
label values comply_surv3alt complyalt
label var comply_surv3exp "Compliance Statement 3: Ban orgs 5 point scale"
label var comply_surv3alt "Compliance Statement 3: Ban orgs 3 point scale -+"
label var comply_surv3 "Compliance Statement 3: Ban orgs 3 point scale"

gen comply_surv4 = . 

replace comply_surv4 = 2 if listshpolicies_answersitems4 == "strongly agree with A" | listshpolicies_answersitems4=="moderately agree with A"
replace comply_surv4 = 1 if listshpolicies_answersitems4 == "Neutral"
replace comply_surv4 = 0 if listshpolicies_answersitems4 == "strongly agree with B" | listshpolicies_answersitems4=="moderately agree with B"
label values comply_surv4 comply
tab comply_surv4

gen comply_surv4exp = .
replace comply_surv4exp = -2 if listshpolicies_answersitems4 == "strongly agree with B"
replace comply_surv4exp = -1 if listshpolicies_answersitems4 == "moderately agree with B"
replace comply_surv4exp = 0 if listshpolicies_answersitems4 == "Neutral"
replace comply_surv4exp = 1 if listshpolicies_answersitems4 == "moderately agree with A"
replace comply_surv4exp = 2 if listshpolicies_answersitems4 == "strongly agree with A"
label values comply_surv4exp complyexp
tab comply_surv4 comply_surv4exp

gen comply_surv4alt = comply_surv4
recode comply_surv4alt 0=-1 1=0 2=1
label values comply_surv4alt complyalt
label var comply_surv4exp "Compliance Statement 4: Close newspapers 5 point scale"
label var comply_surv4alt "Compliance Statement 4: Close newspapers 3 point scale -+"
label var comply_surv4 "Compliance Statement 4: Close newspapers 3 point scale"

gen comply_surv5 = . 
replace comply_surv5 = 2 if listshpolicies_answersitems5 == "strongly agree with A" | listshpolicies_answersitems5=="moderately agree with A"
replace comply_surv5 = 1 if listshpolicies_answersitems5 == "Neutral"
replace comply_surv5 = 0 if listshpolicies_answersitems5 == "strongly agree with B" | listshpolicies_answersitems5=="moderately agree with B"
label values comply_surv5 comply
tab comply_surv5

gen comply_surv5exp = .
replace comply_surv5exp = -2 if listshpolicies_answersitems5 == "strongly agree with B"
replace comply_surv5exp = -1 if listshpolicies_answersitems5 == "moderately agree with B"
replace comply_surv5exp = 0 if listshpolicies_answersitems5 == "Neutral"
replace comply_surv5exp = 1 if listshpolicies_answersitems5 == "moderately agree with A"
replace comply_surv5exp = 2 if listshpolicies_answersitems5 == "strongly agree with A"
label values comply_surv5exp complyexp
tab comply_surv5 comply_surv5exp

gen comply_surv5alt = comply_surv5
recode comply_surv5alt 0=-1 1=0 2=1
label values comply_surv5alt complyalt
label var comply_surv5exp "Compliance Statement 5: Ban different views 5 point scale"
label var comply_surv5alt "Compliance Statement 5: Ban different views 3 point scale -+"
label var comply_surv5 "Compliance Statement 5: Ban different views 3 point scale"


gen comply_surv = (comply_surv1+ comply_surv2+ comply_surv3+ comply_surv4+ comply_surv5)/5
label var comply_surv "Additive scale of 5 compliance questions"

drop listshpolic*


*******************************************
****************************************
/*demographics*/
gen citizenship1 = ""
gen citizenship2 = ""
gen citizenship3 = ""
gen citizenship4 = ""
gen citizenship_count =0
label var citizenship1 "R's 1st citizenship"
label var citizenship2 "R's 2nd citizenship"
label var citizenship3 "R's 3rd citizenship"
label var citizenship4 "R's 4th citizenship"
label var citizenship_count "R's number of reported citizenships"

#delimit ;
local ctzopts ctz_countryoption1_response-ctz_countryoption13_response 	
	ctz_countryother_response;
#delimit cr


foreach opt of varlist `ctzopts' { 
	tostring `opt', replace 
	replace `opt' = "" if `opt' == "."
	replace citizenship_count = citizenship_count +1 if !mi(`opt')
	replace `opt' = strupper(`opt')
	}

replace ctz_countryother_response = "JORDAN" if ctz_countryother_response == "JORDEN"
replace ctz_countryother_response = "SOMALIA" if ctz_countryother_response == "SOMALI"
replace ctz_countryother_response = "CANADA" if ctz_countryother_response == "CANADIAN"

#delimit ;
foreach opt of varlist `ctzopts' { ;
	replace citizenship4 = `opt' if !mi(citizenship1) 
		& !mi(citizenship2)
		& !mi(citizenship3)
		& !mi(`opt');
	replace citizenship3 = `opt' if !mi(citizenship1) 
		& !mi(citizenship2)
		& mi(citizenship4)
		& !mi(`opt');
	replace citizenship2 = `opt' if !mi(citizenship1) 
		&  mi(citizenship3)
		& !mi(`opt');
	replace citizenship1 = `opt' if !mi(`opt') & mi(citizenship1);
};
#delimit cr
*list citizenship_count if citizenship1 == "CANADA,JORDAN"
*add canada to second citizenship
replace citizenship1 = "JORDAN" if subject_id ==   81 
replace citizenship2 = "CANADA" if subject_id ==   81 

drop ctz_country*

gen woman = .
replace woman=1 if gender_response=="female"
replace woman=0 if gender_response=="male"
label var woman "1 if R is female, 0 if male"

rename gender_response gender
label var gender "R's gender"

gen born_uae = .
replace born_uae = 1 if birth_country_response=="UAE"
replace born_uae = 0 if birth_country_response=="Egypt"
replace born_uae = 0 if birth_country_response=="India"
replace born_uae = 0 if birth_country_response=="Iran"
replace born_uae = 0 if birth_country_response=="Kuwait"
replace born_uae = 0 if birth_country_response=="Lebanon"
replace born_uae = 0 if birth_country_response=="Other"
replace born_uae = 0 if birth_country_response=="Pakistan"
replace born_uae = 0 if birth_country_response=="Palestine"
replace born_uae = 0 if birth_country_response=="Saudi Arabia"
replace born_uae = 0 if birth_country_response=="Syria"
label var born_uae "1 if R is born in UAE, 0 otherwise"

rename birth_country_response birth_country
label var birth_country "Country of R's birth"

rename birth_countryother* birth_country_other
label var birth_country_other "Other birth-country [open-ended]"

rename years_uae_response years_uae
label var years_uae "Years R has resided in UAE"

rename age_response age
label var age "R's age"

gen emirate = .
replace emirate = 0 if emirate_response=="Other Emirate"
replace emirate = 1 if emirate_response=="Dubai"
replace emirate = 2 if emirate_response=="Abu Dhabi"
label define emirates 0 "Other" 1 "Dubai" 2 "Abu Dhabi"
label values emirate emirates
label var emirate "Emirate in which R resides"
drop emirate_response

gen emirate_ad = cond(emirate==2, 1, 0) if emirate~=.
label define emiratesbin 1 "Abu Dhabi" 0 "Other"
label values emirate_ad emiratesbin
label var emirate_ad "1 if R resides in Abu Dhabi, 0 otherwise"

rename  emirateother_response emirate_other
label var emirate_other "R's reported *other* emirate [open-ended]"

gen muslim = .
replace muslim = 1 if religion_response=="Muslim"
replace muslim = 0 if religion_response~="Muslim"
label define islam 1 "Muslim" 0 "Other"
label values muslim islam
label var muslim "1 if R is muslim, 0 otherwise"

gen religion = religion_response
label var religion "R's religion"
drop religion_response

gen religion_other =  religionother_response
label var religion_other "Other religion open-ended"
drop religionother_response

gen uae_school = .
replace uae_school = 1 if school_uae_response=="yes"
replace uae_school = 0 if school_uae_response=="no"
label define school 1 "Attended UAE Public School" 0 "Attended Other School"
label values uae_school school
label var uae_school "1 if R attended UAE public school, 0 otherwise"
drop school_uae_response

gen fam_gov = .
replace fam_gov = 1 if govt_uae_response=="yes"
replace fam_gov = 0 if govt_uae_response=="no"
label define govt 1 "Family in Government" 0 "No Family in Government"
label values fam_gov govt
label var fam_gov "1 if R has family in UAE govt, 0 otherwise"

drop govt_uae_response

*There was one missing observation here
gen rel_imp = .
replace rel_imp = 2 if religiosity_response=="religious"
replace rel_imp = 1 if religiosity_response=="somewhat religious"
replace rel_imp = 0 if religiosity_response=="not religious"
replace rel_imp = . if religiosity_response=="Other"
label define important 0 "Not Religious" 1 "Somewhat Religious" 2 "Very Religious"
label values rel_imp important
tab rel_imp
label var rel_imp "R's religiosity"

gen rel_imp_2 =.
replace rel_imp_2 = 1 if religiosity_response=="religious"
replace rel_imp_2 = 0 if religiosity_response!="religious"
label var rel_imp_2 "1 if R is religious, 0 otherwise"
drop religiosity_response

rename religiosityother_response rel_imp_other
label var rel_imp_other "R's *other* religiosity [open-ended]"

gen work = .
replace work = 0 if work_status_response == "do not work"
replace work = 1 if work_status_response == "part time"
replace work = 2 if work_status_response == "full time"
label define workstat 0 "Do Not Work" 1 "Part Time" 2 "Full Time"
label values work workstat
label var work "R's work status"
drop work_status_response

gen fam_income = .
replace fam_income = 0 if family_income_response=="A. Below 50,000 AED"
replace fam_income = 1 if family_income_response=="B. 50,000-99,999 AED"
replace fam_income = 2 if family_income_response=="C. 100,000-149,999 AED"
replace fam_income = 3 if family_income_response=="D. 150,000-199,999 AED"
replace fam_income = 4 if family_income_response=="E. 200,000-249,999 AED"
replace fam_income = 5 if family_income_response=="F. 250,000-299,999 AED"
replace fam_income = 6 if family_income_response=="G. 300,000-349,999 AED"
replace fam_income = 7 if family_income_response=="H. 350,000-399,999 AED"
replace fam_income = 8 if family_income_response=="I. 400,000 AED or greater"

#delimit ; 
label define income 0 "Below 50,000 AED" 
1 "50,000-99,999 AED"
2 "100,000-149,999 AED"
3 "150,000-199,999 AED"
4 "200,000-249,999 AED"
5 "250,000-299,999 AED"
6 "300,000-349,999 AED"
7 "350,000-399,999 AED"
8 "400,000 AED or greater";
#delimit cr

label values fam_income income
label var fam_income "R's hh income"

gen fam_loincome = cond(fam_income==0,1,0) if fam_income~=.
label define loincome 1 "Below 50,000 AED" 0 "Above 50,000 AED"
label values fam_loincome loincome
label var fam_loincome "1 if R's household makes below 50,000 AED, 0 if above"

gen fam_loincome_nm = cond(fam_income==0,1,0) if fam_income~=.
replace fam_loincome_nm = 1 if fam_income==.
label define loincome_nm 1 "Below 50,000 AED" 0 "Above 50,000 AED or missing"
label values fam_loincome_nm loincome_nm
label var fam_loincome_nm "1 if R's household makes below 50,000 AED, 0 if above or missing"

drop family_income_response

rename income_indiv_response income_indiv
*if don't want to share income
replace income_indiv = .a if income_indiv == -1
label var income_indiv "R's individual income"

***********************************
**********************************
/*Mood Pre-Experiment Survey*/
/*Mood Pre-Experiment Survey, STAI-6 scoring scale*/
gen mood_calm_stai = .
replace mood_calm_stai=4 if mood_calm_response=="not at all"
replace mood_calm_stai=3 if mood_calm_response =="somewhat"
replace mood_calm_stai=2 if mood_calm_response =="moderately"
replace mood_calm_stai=1 if mood_calm_response =="completely"
label define mood_positive 4 "Not at all" 3 "Somewhat" 2 "Moderately" 1 "Completely"
label values mood_calm_stai mood_positive
label var mood_calm_stai "R's pre-treatment *calm* rating"

gen mood_tense_stai = .
replace mood_tense_stai=1 if mood_tense_response=="not at all"
replace mood_tense_stai=2 if mood_tense_response =="somewhat"
replace mood_tense_stai=3 if mood_tense_response =="moderately"
replace mood_tense_stai=4 if mood_tense_response =="completely"
label define mood_negative 1 "Not at all" 2 "Somewhat" 3 "Moderately" 4 "Completely"
label values mood_tense_stai mood_negative
label var mood_tense_stai "R's pre-treatment *tense* rating"

gen mood_upset_stai = .
replace mood_upset_stai=1 if mood_upset_response=="not at all"
replace mood_upset_stai=2 if mood_upset_response =="somewhat"
replace mood_upset_stai=3 if mood_upset_response =="moderately"
replace mood_upset_stai=4 if mood_upset_response =="completely"
label values mood_upset_stai mood_negative
label var mood_upset_stai "R's pre-treatment *upset* rating"

gen mood_relaxed_stai = .
replace mood_relaxed_stai=4 if mood_relaxed_response=="not at all"
replace mood_relaxed_stai=3 if mood_relaxed_response =="somewhat"
replace mood_relaxed_stai=2 if mood_relaxed_response =="moderately"
replace mood_relaxed_stai=1 if mood_relaxed_response =="completely"
label values mood_relaxed_stai mood_positive
label var mood_relaxed_stai "R's pre-treatment *relaxed* rating"

gen mood_content_stai = .
replace mood_content_stai=4 if mood_content_response=="not at all"
replace mood_content_stai=3 if mood_content_response =="somewhat"
replace mood_content_stai=2 if mood_content_response =="moderately"
replace mood_content_stai=1 if mood_content_response =="completely"
label values mood_content_stai mood_positive
label var mood_content_stai "R's pre-treatment *content* rating"

gen mood_worried_stai = .
replace mood_worried_stai=1 if mood_worried_response=="not at all"
replace mood_worried_stai=2 if mood_worried_response =="somewhat"
replace mood_worried_stai=3 if mood_worried_response =="moderately"
replace mood_worried_stai=4 if mood_worried_response =="completely"
label values mood_worried_stai mood_negative
label var mood_worried_stai "R's pre-treatment *worried* rating"

gen sum_mood_stai_pre=(mood_calm_stai+mood_tense_stai+mood_upset_stai+mood_relaxed_stai+mood_content_stai+mood_worried_stai)
gen total_stai_pre=(sum_mood_stai_pre*(20/6))
label var sum_mood_stai_pre "Additive sum all R's pre-treatment STAI assessments"
label var total_stai_pre "R's standardized pre-treatment STAI score"

/*Mood Post-Experiment Survey, STAI-6 scoring scale*/
gen mood_final_calm_stai = .
replace mood_final_calm_stai=4 if mood_final_calm_response=="not at all"
replace mood_final_calm_stai=3 if mood_final_calm_response =="somewhat"
replace mood_final_calm_stai=2 if mood_final_calm_response =="moderately"
replace mood_final_calm_stai=1 if mood_final_calm_response =="completely"
label values mood_final_calm_stai mood_positive
label var mood_final_calm_stai "R's post-treatment *calm* rating"

gen mood_final_tense_stai = .
replace mood_final_tense_stai=1 if mood_final_tense_response=="not at all"
replace mood_final_tense_stai=2 if mood_final_tense_response =="somewhat"
replace mood_final_tense_stai=3 if mood_final_tense_response =="moderately"
replace mood_final_tense_stai=4 if mood_final_tense_response =="completely"
label values mood_final_tense_stai mood_negative
label var mood_final_tense_stai "R's post-treatment *tense* rating"

gen mood_final_upset_stai = .
replace mood_final_upset_stai=1 if mood_final_upset_response=="not at all"
replace mood_final_upset_stai=2 if mood_final_upset_response =="somewhat"
replace mood_final_upset_stai=3 if mood_final_upset_response =="moderately"
replace mood_final_upset_stai=4 if mood_final_upset_response =="completely"
label values mood_final_upset_stai mood_negative
label var mood_final_upset_stai "R's post-treatment *upset* rating"

gen mood_final_relaxed_stai = .
replace mood_final_relaxed_stai=4 if mood_final_relaxed_response=="not at all"
replace mood_final_relaxed_stai=3 if mood_final_relaxed_response =="somewhat"
replace mood_final_relaxed_stai=2 if mood_final_relaxed_response =="moderately"
replace mood_final_relaxed_stai=1 if mood_final_relaxed_response =="completely"
label values mood_final_relaxed_stai mood_positive 
label var mood_final_relaxed_stai "R's post-treatment *relaxed* rating"

gen mood_final_content_stai = .
replace mood_final_content_stai=4 if mood_final_content_response == "not at all"
replace mood_final_content_stai=3 if mood_final_content_response == "somewhat"
replace mood_final_content_stai=2 if mood_final_content_response == "moderately"
replace mood_final_content_stai=1 if mood_final_content_response == "completely"
label values mood_final_content_stai mood_positive 
label var mood_final_content_stai "R's post-treatment *content* rating"

gen mood_final_worried_stai = .
replace mood_final_worried_stai=1 if mood_final_worried_response == "not at all"
replace mood_final_worried_stai=2 if mood_final_worried_response == "somewhat"
replace mood_final_worried_stai=3 if mood_final_worried_response == "moderately"
replace mood_final_worried_stai=4 if mood_final_worried_response == "completely"
label values mood_final_worried_stai mood_negative
label var mood_final_worried_stai "R's post-treatment *worried* rating"

gen sum_mood_stai_post=(mood_final_calm_stai+mood_final_tense_stai+mood_final_upset_stai+mood_final_relaxed_stai+mood_final_content_stai+mood_final_worried_stai)
gen total_stai_post=(sum_mood_stai_post*(20/6))
label var sum_mood_stai_post "Additive sum all R's post-treatment STAI assessments"
label var total_stai_post  "R's standardized post-treatment STAI score"

gen mood_dif_stai = (sum_mood_stai_pre - sum_mood_stai_post)
gen mood_dif_stai_total = (total_stai_pre -total_stai_post)
label var mood_dif_stai "R's Difference in raw STAI totals pre and post-treatment"
label var mood_dif_stai_total "R's Difference in STAI totals pre and post-treatment"

drop mood_*_response

/*manipulation check post-experiment survey*/
encode see_anything_1_response , generate(see_anything)
label var see_anything "Did R report seeing anything"
drop see_anything_1_response

encode face_recognition_response, generate(face_recognition)
label var face_recognition "Did R recognize face?"
drop face_recognition_response

gen stars = .
replace stars = 1 if seen_imagesoption1_response == "Stars"
replace stars = 0 if mi(seen_imagesoption1_response) 
label var stars "1 if R reported seeing stars in image, 0 otherwise"

gen faces = .
replace faces = 1 if seen_imagesoption2_response=="Faces"
replace faces = 0 if mi(seen_imagesoption2_response) 
label var faces "1 if R reported seeing face in image, 0 otherwise"

gen nature = .
replace nature = 1 if seen_imagesoption3_response == "Nature"
replace nature = 0 if mi(seen_imagesoption3_response)
label var nature "1 if R reported seeing nature in image, 0 otherwise"

gen other_images = .
replace other_images = 1 if seen_imagesoption4_response == "Other images"
replace other_images = 0 if mi(seen_imagesoption4_response)
label var other_images "1 if R reported seeing other images in image, 0 otherwise"

rename seen_imagesother_response other_images_what
label var other_images_what "What other image did R see?"

drop seen_i*

rename whose_face_response whose_face
label var whose_face "Who did R see [open-ended]"

rename final_thoughts_response final_thoughts
label var final_thoughts "R's final thoughts on study [open-ended]"

**order variables in dataset
local prestuff subject_id build group block start_time end_time* date start_pwd end_pwd policy_num display_refresh_rate
#delimit ;
local outcomes treat treat_dichot comp*  income_earned reported_income income_post_tax
 income_unreported  audited percent* donat*  endorse*;
local demog age years_uae born_uae gender woman birth_country* muslim work
 citizenship* religion* rel_imp* uae_school emirate* fam* income_indiv;
#delimit cr
local practice *_practice*
local mood mood*  *mood* total_stai*
local manipcheck see_anything face_recognition faces stars nature other_images* whose_face final_thoughts
local other auditor*

order `prestuff' `outcomes' `demog' `mood' `manipcheck' `practice' `other'

save clean_labels_bepz_data.dta, replace
